﻿using HCD.Dtos;
using HCD.Project;
using Enterprise.Entities.Dtos;
using HCD.Project.Dtos;
using Microsoft.AspNetCore.Mvc;
using Partner.Utility;
using System.Collections.Generic;
using System.Threading.Tasks;
using HCD.Entities.Dtos;
using Abp.Application.Services.Dto;

// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace HCD.Web.MDC.Controllers.ApiControllers.Sys
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProjectController : EnterpriseControllerBase
    {
        public IProjectAppService ProjectAppService { get; set; }

        [HttpGet]
        public async Task<BizResult<List<OperatorPoolListDto>>> GetOperatorPool()
        {
            var result = new BizResult<List<OperatorPoolListDto>>() { Success = false };
            result.Data = await ProjectAppService.GetOperatorPool();
            result.Success = true;
            return result;
        }
        [HttpGet]
        public async Task<PagedResultDto<RequirementPoolListDto>> GetRquirementPool([FromQuery]PagedAndSortedInputDto input)
        {
            return await ProjectAppService.GetRquirementPool(input);
        }
        [HttpGet]
        public async Task<PagedResultDto<ProjectPoolListDto>> GetProjectPool([FromQuery]PagedAndSortedInputDto input)
        {
            return await ProjectAppService.GetProjectPool(input);
        }
        [HttpGet]
        public async Task<PagedResultDto<ProjectPersonalListDto>> GetProjectPersonal([FromQuery]GetProjectPersonalInput input)
        {
            input.OperatorID = CurrentOperator.EmpNo;
            return await ProjectAppService.GetProjectPersonal(input);
        }
        [HttpPost]
        public async Task<BizResult<bool>> SaveProjectPersonal([FromBody]ProjectPersonalEditDto input)
        {
            input.OperatorID = CurrentOperator.EmpNo;
            var result = new BizResult<bool>() { Success = false };
            await ProjectAppService.SaveProjectPersonal(input);
            result.Success = true;
            return result;
        }
        [HttpPost]
        public async Task<BizResult<bool>> DelProjectPersonal([FromBody]int id)
        {
            var result = new BizResult<bool>() { Success = false };
            await ProjectAppService.DelProjectPersonal(id);
            result.Success = true;
            return result;
        }
    }
}
